import {PageModel} from "/@/api/system/model/CommonModel";
import {TemplateModel} from "/@/api/generator/model/TemplateModel";
import axios from "/@/utils/http/axios";
import {MethodEnum} from "/@/utils/http/axios/enum/method-enum";
import {CreateCodeQueryModel, TableInfoModel, TableInfoQueryModel} from "/@/api/generator/model/TableInfoModel";

/**
 * 新增表信息
 * @param isHint
 * @param callBack
 */
export function insertTableInfo(tableName: string,callBack?: Function):Promise<string[]> {
    return axios.httpRequest("/generator/table/info/insertTableInfo", MethodEnum.GET, {tableName}, {callBack});
}

/**
 * 修改表信息
 * @param data
 * @param callBack
 */
export function updateTableInfoByTableId(data: TableInfoModel,callBack?: Function):Promise<string[]> {
    return axios.httpRequest("/generator/table/info/updateTableInfoByTableId", MethodEnum.POST, data, {callBack});
}


/**
 * 分页查询表信息
 * @param data
 * @param callBack
 */
export function listTableInfoPage(data: TableInfoQueryModel,callBack?: Function):Promise<PageModel<TableInfoModel[]>> {
    return axios.httpRequest("/generator/table/info/listTableInfoPage", MethodEnum.GET, data, {callBack});
}
/**
 * 查询表信息列表
 * @param data
 * @param callBack
 */
export function listTableInfo(data: TableInfoQueryModel,callBack?: Function):Promise<TableInfoModel[]> {
    return axios.httpRequest("/generator/table/info/listTableInfo", MethodEnum.GET, data, {callBack});
}


/**
 * 根据表Id查询表信息
 * @param data
 * @param callBack
 */
export function selectTableInfoByTableId(tableId: string,callBack?: Function):Promise<PageModel<TableInfoModel[]>> {
    return axios.httpRequest("/generator/table/info/selectTableInfoByTableId", MethodEnum.GET, {tableId}, {callBack});
}

/**
 * 根据表id删除表信息
 * @param tableId
 * @param callBack
 */
export function deleteTableInfoByTableId(tableId: string,callBack?: Function):Promise<PageModel<TableInfoModel[]>> {
    return axios.httpRequest("/generator/table/info/deleteTableInfoByTableId", MethodEnum.GET, {tableId}, {callBack});
}



/**
 * 下载生成的code
 * @param data
 * @param callBack
 */
export function downloadCode(data: CreateCodeQueryModel,callBack?: Function):Promise<PageModel<TableInfoModel[]>> {
    return axios.downloadRequest("/generator/create/code/downloadCode", MethodEnum.POST, data, {callBack});
}


/**
 * 后端生成代码
 * @param data
 * @param callBack
 */
export function createCode(data: CreateCodeQueryModel,callBack?: Function):Promise<PageModel<TableInfoModel[]>> {
    return axios.httpRequest("/generator/create/code/createCode", MethodEnum.POST, data, {callBack});
}